﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Page>" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Src="TourInfo.ascx" TagName="TourInfo" TagPrefix="uc1" %>
<%@ Register Src="TourDetail.ascx" TagName="TourDetail" TagPrefix="uc2" %>
<%@ Register Src="TourGuest.ascx" TagName="TourGuest" TagPrefix="uc3" %>
<%@ Register Src="TourFeedback.ascx" TagName="TourFeedback" TagPrefix="uc4" %>
<%@ Import Namespace="Buffalo.Administration.DAL" %>
<%@ Import Namespace="Buffalo.Administration.Enum" %>
<%@ Import Namespace="Buffalo.Lib.Common" %>
<%@ Import Namespace="Buffalo.Tourism.DAL" %>
<%@ Import Namespace="Buffalo.Tourism.DAL.Models" %>
<%@ Import Namespace="Buffalo.Tourism.Enum" %>
<%@ Import Namespace="Buffalo.Web.Areas.Tourism" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                bool visible = false;
                bool hasEditPermission = new PermissionDAL().HasPermission(GeneralVar.gLoggedUserName, "TourInfo", enuPermissionType.Edit);
                if (hasEditPermission)
                {
                    string IDTour = Util.ToSafeString(ViewData["IDTour"]);
                    hidIDTour.Value = IDTour;

                    if (string.IsNullOrEmpty(IDTour) || IDTour.Equals("0"))
                        visible = true;
                    else
                    {
                        Tour tour = new TourProgramDAL().GetTour(IDTour);

                        if (string.IsNullOrEmpty(tour.LocationRoleName) || GeneralVar.gLoggedRoleName == tour.LocationRoleName)
                            visible = true;
                    }
                }
                btnSave.Visible = visible;
                btnSaveAndClose.Visible = btnSave.Visible;
                btnExportExcel.Visible = new PermissionDAL().HasPermission(GeneralVar.gLoggedUserName, "TourInfo", enuPermissionType.View); ;
            }
        }
    </script>
    <script type="text/javascript">
        var saveFormHandler = function () {
            var tabIndex = getCurrentTabIndex();
            if (tabIndex == 0) {    //tour info
                dsGuest.save();
                TourInfoForm.form.submit({ waitMsg: 'Saving...', params: { id: getID() }, success: successHandlerSave, failure: failureHandler });
            }
            if (tabIndex == 1) {    //tour detail
                dsListTourDetail.save();
            }
            if (tabIndex == 2) {    //tour feedback
                TourFeedbackForm.form.submit({ waitMsg: 'Saving...', params: { id: getID() }, success: successHandlerSave, failure: failureHandler });
                dsFeedback.save();
                dsFeedbackDetail.save();
            }
        };
        var saveAndCloseFormHandler = function () {
            var tabIndex = getCurrentTabIndex();
            if (tabIndex == 0) {    //tour info
                dsGuest.save();
                TourInfoForm.form.submit({ waitMsg: 'Saving...', params: { id: getID() }, success: successHandlerSaveClose, failure: failureHandler });
            }
            if (tabIndex == 1) {    //tour detail
                dsListTourDetail.save();
                hideTourEditorWindow();
            }
            if (tabIndex == 2) {    //tour feedback
                TourFeedbackForm.form.submit({ waitMsg: 'Saving...', params: { id: getID() }, success: successHandlerSaveClose, failure: failureHandler });
                dsFeedback.save();
                dsFeedbackDetail.save();
                hideTourEditorWindow();
            }
        };
        var dataChanged = false;
        var openExportExcelHandler = function (IDTour) {
            var win = ExportExcelWindow;
            win.autoLoad.params.IDTour = IDTour;
            win.setTitle('Export tour to excel');
            win.show();
        };

        function zeroPad(num, places) {
            var zero = places - num.toString().length + 1;
            return Array(+(zero > 0 && zero)).join("0") + num;
        }
        var generateTourCode = function (cboOwnCompany, TourCodeControl) {
            var ownCompanyName = cboOwnCompany.getValue();
            var preTourCode = ownCompanyName.substr(0, 3);
            var curTourCode = TourCodeControl.getValue();
            if (curTourCode.length > 11) {
                var leftPart = curTourCode.substr(4);
                preTourCode = preTourCode + '-' + leftPart;
            }
            else {
                var now = new Date();
                var newDayPart = now.getFullYear().toString().substr(2, 2) + zeroPad(now.getMonth() + 1, 2) + zeroPad(now.getDate() + 1, 2);
                preTourCode = preTourCode + '-' + newDayPart + '-';
            }
            TourCodeControl.setValue(preTourCode);
        };
        var failureHandler = function (form, action) {
            var msg = "";
            if (action.failureType == "client" || (action.result && action.result.errors && action.result.errors.length > 0)) {
                msg = "Please check fields";
            } else if (action.result && action.result.extraParams.msg) {
                msg = action.result.extraParams.msg;
            } else if (action.response) {
                msg = action.response.responseText;
            }

            Ext.Msg.show({
                title: "Save Error",
                msg: msg,
                buttons: Ext.Msg.OK,
                icon: Ext.Msg.ERROR
            });
        };
        var successHandlerSaveClose = function (form, action) {
            successHandlerSave(form, action);
            hideTourEditorWindow();
        };
        var getCurrentTabIndex = function () {
            return TourTabPanel.items.indexOf(TourTabPanel.getActiveTab());
        };
        var successHandlerSave = function (form, action) {
            var tabIndex = getCurrentTabIndex();

            if (tabIndex == 0) {    //tour info

                if (action.result && action.result.extraParams && action.result.extraParams.newID) {

                    dsTour.getAt(0).id = action.result.extraParams.newID;
                    if (dsTour.getAt(0).newRecord) {
                        delete dsTour.getAt(0).newRecord;
                    }
                } else {
                    Ext.MessageBox.alert("Success", "Tour has been saved!");
                }

                dataChanged = true;

                if (action.options.params.setNew) {
                    TourInfoForm.form.reset();
                    TourFeedbackForm.form.reset();
                    dsTour.removeAll();

                    var rec = new dsTour.recordType();
                    rec.newRecord = true;
                    dsTour.add(rec);

                }
                if (action.result && action.result.extraParams && action.result.extraParams.newID) {

                    hidIDTour.setValue(action.result.extraParams.newID);
                }

                //reload ds
                dsGuest.load();

                dsListTourDetail.load();
                dsFeedback.load();
            }
            if (tabIndex == 1) {    //tour detail
                dsListTourDetail.save();
            }
        };

        var getID = function () {
            var IDTour = (dsTour.getCount() > 0 && !dsTour.getAt(0).newRecord) ? dsTour.getAt(0).id : "";
            return IDTour;
        };

        var hideTourEditorWindow = function () {
            parent.TourEditorWindow.hide();
            if (dataChanged)
                parent.dsTour.reload();
        };

        function GetCurrentDate() {
            var today = new Date();
            today.format("mm/dd/yyyy");
            return today;
        }
        var tourLoaded = function (store, records) {
            if (records.length > 0) {
                TourInfoForm.form.loadRecord(records[0]);
                TourFeedbackForm.form.loadRecord(records[0]);

                if (dsTour.getAt(0).id == '' || dsTour.getAt(0).id == '0') {
                    txtStartDate = Ext.getCmp('StartDate');
                    txtStartDate.setValue(GetCurrentDate());

                    txtCreatedDate = Ext.getCmp('CreatedDate');
                    txtCreatedDate.setValue(GetCurrentDate());
                }
            } else {
                TourInfoForm.form.reset();
                TourFeedbackForm.form.reset();
            }

            TourTabPanel.el.unmask();
        };

        var commandHandler = function (cmd, record) {
            switch (cmd) {
                case "edit":
                    var win = TourDetailEditorWindow;
                    win.autoLoad.params.IDTourDetail = record.id;
                    win.setTitle('Edit Tour date: ' + record.data.TourDate + ' ' + record.data.DayTime);
                    win.show();
                    break;
                case "delete":
                    Ext.Msg.confirm('Warning', 'Delete Record?', function (btn) {
                        if (btn == "yes") {
                            dsTour.remove(record);
                            dsTour.save();
                        }
                    });
                    break;
            }
        };
        function GetMonthFromMonthText(monthText) {
            var monthNum = 0;
            switch (monthText) {
                case "Jan":
                    monthNum = "01";
                    break;
                case "Feb":
                    monthNum = "02";
                    break;
                case "Mar":
                    monthNum = "03";
                    break;
                case "Apr":
                    monthNum = "04";
                    break;
                case "May":
                    monthNum = "05";
                    break;
                case "Jun":
                    monthNum = "06";
                    break;
                case "Jul":
                    monthNum = "07";
                    break;
                case "Aug":
                    monthNum = "08";
                    break;
                case "Sep":
                    monthNum = "09";
                    break;
                case "Oct":
                    monthNum = "10";
                    break;
                case "Nov":
                    monthNum = "11";
                    break;
                case "Dec":
                    monthNum = "12";
                    break;
            }
            return monthNum;
        }
        function render(value, metadata, record, rowIndex, colIndex, store) {
            if (colIndex < 2)
                return;
            var retVal;
            switch (record.data.Status) {
                case 1:
                    retVal = colIndex == 10 ? 'Booked' : value;
                    break;
                case 2:
                    metadata.style += "background-color: #FFAABB;";
                    retVal = colIndex == 10 ? 'Done' : value;
                    break;
                case 3:
                    metadata.style += "background-color: #FFFAC8;";
                    retVal = colIndex == 10 ? 'Running' : value;
                    break;
                default:
                    retVal = value;
            }
            if (colIndex == 7 || colIndex == 6) {
                if (value) {
                    var fullDate = value.toString().substring(0, 15);
                    var monthText = fullDate.substring(4, 7);
                    var month = GetMonthFromMonthText(monthText);
                    var day = fullDate.substring(8, 10);
                    var year = fullDate.substring(11, 15);
                    if (year != '1900')
                        retVal = day + "/" + month + "/" + year;
                    else
                        retVal = '';
                }
            }
            return retVal;
        }       
    </script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server">
    </ext:ResourceManager>
    <ext:Store ID="dsTour" runat="server">
        <Proxy>
            <ext:HttpProxy Url="/TourProgram/GetTour/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="TourCode" />
                    <ext:RecordField Name="GuestNum" />
                    <ext:RecordField Name="RoomNum" />
                    <ext:RecordField Name="StartDate" Type="Date" DateFormat="yyyy-MM-ddThh:mm:ss" />
                    <ext:RecordField Name="EndDate" Type="Date" DateFormat="yyyy-MM-ddThh:mm:ss" />
                    <ext:RecordField Name="CreatedDate" Type="Date" DateFormat="yyyy-MM-ddThh:mm:ss" />
                    <ext:RecordField Name="IDNationality" />
                    <ext:RecordField Name="NationalityName" />
                    <ext:RecordField Name="IDBroker" />
                    <ext:RecordField Name="BrokerName" />
                    <ext:RecordField Name="IDOwnCompany" />
                    <ext:RecordField Name="OwnCompanyName" />
                    <ext:RecordField Name="IDLanguage" />
                    <ext:RecordField Name="LanguageName" />
                    <ext:RecordField Name="FeedbackGuestName" />
                    <ext:RecordField Name="FeedbackGuestFrom" />
                    <ext:RecordField Name="FeedbackGuestJob" />
                    <ext:RecordField Name="FeedbackGuestEmail" />
                    <ext:RecordField Name="FeedbackNote" />
                    <ext:RecordField Name="FeedbackOther" />
                    <ext:RecordField Name="FeedbackTourProgress" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="IDTour" Value='<%# ViewData["IDTour"] %>' Mode="Value" AutoDataBind="true" />
        </BaseParams>
        <Listeners>
            <BeforeLoad Handler="#{TourTabPanel}.el.mask('Loading tour...', 'x-mask-loading');" />
            <LoadException Handler="#{TourTabPanel}.el.unmask();" />
            <Load Fn="tourLoaded" />
        </Listeners>
    </ext:Store>
    <ext:Store ID="dsListTourDetail" runat="server" RemoteSort="true" UseIdConfirmation="false" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/TourProgram/GetListTourDetail/" />
        </Proxy>
        <UpdateProxy>
            <ext:HttpWriteProxy Url="/TourProgram/SaveTourDetails/" />
        </UpdateProxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="IDTour" />
                    <ext:RecordField Name="TourDate" />
                    <ext:RecordField Name="DayTime" />
                    <ext:RecordField Name="Program" />
                    <ext:RecordField Name="IDTourGuide" />
                    <ext:RecordField Name="TourGuideName" />
                    <ext:RecordField Name="TourGuideNote" />
                    <ext:RecordField Name="IDHotel" />
                    <ext:RecordField Name="HotelName" />
                    <ext:RecordField Name="HotelNote" />
                    <ext:RecordField Name="IDVehicle" />
                    <ext:RecordField Name="VehicleName" />
                    <ext:RecordField Name="VehicleNote" />
                    <ext:RecordField Name="IDRestaurant" />
                    <ext:RecordField Name="RestaurantName" />
                    <ext:RecordField Name="RestaurantNote" />
                    <ext:RecordField Name="IDPartner" />
                    <ext:RecordField Name="PartnerName" />
                    <ext:RecordField Name="PartnerNote" />
                    <ext:RecordField Name="IDOrgUnit" />
                    <ext:RecordField Name="GuestNum" />
                    <ext:RecordField Name="RoomNum" />
                    <ext:RecordField Name="AirTicketNote" />
                    <ext:RecordField Name="Location" />
                    <ext:RecordField Name="LocationRoleName" />
                    <ext:RecordField Name="Gift1" />
                    <ext:RecordField Name="Gift2" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="IDTour" Value='hidIDTour.getValue()' Mode="Raw" AutoDataBind="true" />
        </BaseParams>
    </ext:Store>
    <ext:Store ID="dsRole" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/Member/GetListRole/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="Name" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>

    <ext:Store ID="dsGuest" runat="server" RemoteSort="true" UseIdConfirmation="false" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/TourProgram/GetListGuest/" />
        </Proxy>
        <UpdateProxy>
            <ext:HttpWriteProxy Url="/Tourism/TourProgram/SaveGuests/" />
        </UpdateProxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="IDTour" />
                    <ext:RecordField Name="FullName" />
                    <ext:RecordField Name="Birthday" Type="Date" DateFormat="yyyy-MM-ddThh:mm:ss" />
                    <ext:RecordField Name="IDNationality" />
                    <ext:RecordField Name="IDCard" />
                    <ext:RecordField Name="Job" />
                    <ext:RecordField Name="TourProgress" />
                    <ext:RecordField Name="ServicedInCountry" />
                    <ext:RecordField Name="FlightNote" />
                    <ext:RecordField Name="Note" />
                    <ext:RecordField Name="Address" />
                    <ext:RecordField Name="PhoneNo" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="FullName" />
            <ext:Parameter Name="IDTour" Value='hidIDTour.getValue()' Mode="Raw" AutoDataBind="true" />
        </BaseParams>
        <SortInfo Field="FullName" Direction="ASC" />
    </ext:Store>
    <ext:Store ID="dsFeedback" runat="server" RemoteSort="true" UseIdConfirmation="false">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/TourProgram/GetListFeedback/" />
        </Proxy>
        <UpdateProxy>
            <ext:HttpWriteProxy Url="/Tourism/TourProgram/SaveFeedbacks/" />
        </UpdateProxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="IDTour" />
                    <ext:RecordField Name="SortNo" />
                    <ext:RecordField Name="IDService" />
                    <ext:RecordField Name="ServiceName" />
                    <ext:RecordField Name="TourGuideName" />
                    <ext:RecordField Name="Feature1" />
                    <ext:RecordField Name="Feature2" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="IDTour" Value='hidIDTour.getValue()' Mode="Raw" AutoDataBind="true" />
        </BaseParams>
        <SortInfo Field="SortNo" Direction="ASC" />
    </ext:Store>
    <ext:Store ID="dsTourGuide" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/TourGuide/GetListTourGuide/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="withDefaultItem" Value="true"  Mode="Value"/>            
            <ext:Parameter Name="cboCriteria" Value="" Mode="Value" />
            <ext:Parameter Name="txtSearchText"  Value="" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>
    <ext:Store ID="dsHotel" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/Catalog/GetListHotel/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="withDefaultItem" Value="true"  Mode="Value"/>            
            <ext:Parameter Name="cboCriteria" Value="" Mode="Value" />
            <ext:Parameter Name="txtSearchText"  Value="" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>
    <ext:Store ID="dsRestaurant" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/Catalog/GetListRestaurant/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="withDefaultItem" Value="true"  Mode="Value"/>            
            <ext:Parameter Name="cboCriteria" Value="" Mode="Value" />
            <ext:Parameter Name="txtSearchText"  Value="" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>
    <ext:Store ID="dsPartner" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/Catalog/GetListPartner/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="withDefaultItem" Value="true"  Mode="Value"/>            
            <ext:Parameter Name="cboCriteria" Value="" Mode="Value" />
            <ext:Parameter Name="txtSearchText"  Value="" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>
    <ext:Store ID="dsVehicle" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/Catalog/GetListVehicle/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="withDefaultItem" Value="true"  Mode="Value"/>            
            <ext:Parameter Name="cboCriteria" Value="" Mode="Value" />
            <ext:Parameter Name="txtSearchText"  Value="" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>

    <ext:Store ID="dsNationality" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/Catalog/GetListNationality/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="withDefaultItem" Value="true"  Mode="Value"/>            
            <ext:Parameter Name="cboCriteria" Value="" Mode="Value" />
            <ext:Parameter Name="txtSearchText"  Value="" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>
    <ext:Store ID="dsLanguage" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/Catalog/GetListLanguage/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="withDefaultItem" Value="true"  Mode="Value"/>            
            <ext:Parameter Name="cboCriteria" Value="" Mode="Value" />
            <ext:Parameter Name="txtSearchText"  Value="" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>
    <ext:Store ID="dsBroker" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/Catalog/GetListBroker/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="withDefaultItem" Value="true"  Mode="Value"/>            
            <ext:Parameter Name="cboCriteria" Value="" Mode="Value" />
            <ext:Parameter Name="txtSearchText"  Value="" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>
    <ext:Store ID="dsCompany" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Tourism/Catalog/GetListCompany/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="0" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" Mode="Value" />
            <ext:Parameter Name="sort" Value="Name" Mode="Value" />
            <ext:Parameter Name="withDefaultItem" Value="true"  Mode="Value"/>            
            <ext:Parameter Name="cboCriteria" Value="" Mode="Value" />
            <ext:Parameter Name="txtSearchText"  Value="" Mode="Value" />
        </BaseParams>
        <SortInfo Field="Name" Direction="ASC" />
    </ext:Store>
    <ext:Viewport ID="mainViewPort" runat="server" Layout="fit">
        <Items>
            <ext:Panel ID="Panel1" runat="server" Border="false" Layout="fit">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:Button ID="btnSave" runat="server" Text="Save" Icon="Disk">
                                <Listeners>
                                    <Click Handler="saveFormHandler()" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="btnSaveAndClose" runat="server" Text="Save and Close" Icon="DiskBlack">
                                <Listeners>
                                    <Click Handler="saveAndCloseFormHandler()" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="btnExportExcel" runat="server" Text="Export to Excel" Icon="PageExcel">
                                <Listeners>
                                    <Click Handler="openExportExcelHandler(getID());" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="btnClose" runat="server" Text="Close" Icon="DoorOut">
                                <Listeners>
                                    <Click Handler="hideTourEditorWindow();" />
                                </Listeners>
                            </ext:Button>
                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:TabPanel ID="TourTabPanel" runat="server" Border="false" LayoutOnTabChange="true">
                        <Items>
                            <ext:Panel ID="panTourInfo" runat="server" Title="Tour Info" Padding="6" Layout="fit"
                                AutoScroll="true">
                                <Content>
                                    <uc1:TourInfo ID="TourInfo1" runat="server" />
                                    <uc3:TourGuest ID="TourGuest2" runat="server" />
                                </Content>
                            </ext:Panel>
                            <ext:Panel ID="panTourDetail" runat="server" Title="Tour Detail" Padding="6" Layout="FitLayout"
                                AutoScroll="true">
                                <Content>
                                    <uc2:TourDetail ID="TourDetail1" runat="server" />
                                </Content>
                            </ext:Panel>
                            <ext:Panel ID="panTourFeedback" runat="server" Title="Tour Feedback" Padding="6"
                                Layout="fit" AutoScroll="true">
                                <Content>
                                    <uc4:TourFeedback ID="TourFeedback1" runat="server" />
                                </Content>
                            </ext:Panel>
                        </Items>
                    </ext:TabPanel>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Viewport>
    <ext:Hidden ID="hidIDTour" runat="server">
    </ext:Hidden>
    <ext:Window ID="TourDetailEditorWindow" runat="server" Icon="ApplicationFormEdit"
        Width="1000" Height="500" Hidden="true" Modal="true" Constrain="true">
        <AutoLoad Url="/Tourism/TourProgram/TourDetailEditor/" Mode="IFrame" TriggerEvent="show"
            ReloadOnEvent="true" ShowMask="true" MaskMsg="Loading Tour detail...">
            <Params>
                <ext:Parameter Name="IDTourDetail" Value="" Mode="Value" />
            </Params>
        </AutoLoad>
    </ext:Window>
    <ext:Window ID="ExportExcelWindow" runat="server" Icon="ArrowIn" Width="800" Height="500"
        Hidden="true" Modal="true" Constrain="true">
        <AutoLoad Url="/Tourism/TourProgram/ExportExcelView/" Mode="IFrame" TriggerEvent="show"
            ReloadOnEvent="true" ShowMask="true" MaskMsg="Opening...">
            <Params>
                <ext:Parameter Name="IDTour" Value="" Mode="Value" />
            </Params>
        </AutoLoad>
    </ext:Window>
</body>
</html>
